package com.eryos.android.cigarettecounter.ui;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.widget.Button;

import com.eryos.android.cigarettecounter.R;

/**
 * Project : CigaretteCounter Author : Olivier Combe URL : http://eryos.fr/CigaretteCounter/
 * 
 * Copyright(C)2011 - Olivier Combe
 * 
 * Licensed under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 * 
 * @version \$Revision.*\$
 * @author Olivier Combe
 */
public class Credits extends Dialog {

    /** Logger Tag. */
    private static final String LOG_TAG = "ChartPopup";

    /* UI Elements */
    private Button closeButton;

    /**
     * Create a new 'Credits' page.
     * 
     * @param contextArg
     *            application context
     */
    public Credits(final Context contextArg) {
        super(contextArg);

        Log.w(LOG_TAG, getClass().getSimpleName() + " : new CreditsPopup()");

        this.setContentView(R.layout.credits_dialog);
        this.setTitle("Credits");

        WebView content = (WebView) findViewById(R.id.content_label);
        content.loadUrl("file:///android_asset/credits.html");

        closeButton = (Button) findViewById(R.id.popup_share_button);
        closeButton.setEnabled(true);

        this.show();

        /* Share button listener */
        closeButton.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(final View v, final MotionEvent e) {
                if (e.getAction() == MotionEvent.ACTION_DOWN) {
                    dismiss();
                    return false;
                }
                return true;
            }
        });

    }

}
